<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;
use \Firebase\JWT\JWT;
use app\admin\jwt\Jwts;

class Main extends Controller {

    public $sysset = array();
    public $admininfo = array();

    public $uid;

    protected $data = array();

    public function initialize() {
        $this->veToken();
        if (session('admininfo') == "") {
            $url = $this->request->domain(true). '/admin/login';
            header('HTTP/1.1 303 See Other');
            header("Location: $url");
            exit;
        } else {
            $this->admininfo = json_decode(base64_decode(session('admininfo')), true);
        }
        $this->data = request()->param();
        $this->sysset = get_sysset();
//        if (cookie("formtoken") == "") {
//            setcookie('formtoken', md5(rand(1, 999)), time() + 7200, '/');
//        }
    }

    /**
     * 验证token
     */
    private function veToken(){
//        $header = request()->header();
//        if(!isset($header['authorization'])){
//            return json(['data'=>[],'code'=>401],200);
//        }
//
//        $tokendata = explode(' ',$header['authorization']);
//        dump($tokendata);die;
//        $token = $tokendata[1];
//        $arr = Jwts::verifyToken($token);
//        if(empty($arr)){
//            return jsonp_error(401,'认证失败！');
//        }
//        $this->uid = $arr['data']->userid;
    }



}

?>